package com.service.system;

import com.common.ErrorCodeEnum;
import com.common.emums.DataStatus;
import com.common.exception.BusinessException;
import com.common.utils.StringUtils;
import com.core.springSecurity.common.SecurityUtils;

import com.dao.secondary.system.SystemDomainInfoMapper;
import com.model.domain.system.GetSystemDomainInfoDO;
import com.model.pojo.system.SystemDomainInfo;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;



/**
 * @Author: zql
 * @Description: 设备发送域名端口信息服务
 * @Data: 2023-11-21
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class SystemDomainInfoService {
    private final SystemDomainInfoMapper systemDomainInfoMapper;

    public List<SystemDomainInfo> getPageList(GetSystemDomainInfoDO getSystemDomainInfoDO){
        PageHelper.clearPage();
        PageHelper.startPage(getSystemDomainInfoDO.getPage(),getSystemDomainInfoDO.getPageSize(),getSystemDomainInfoDO.getSortRow()+getSystemDomainInfoDO.getSortOrder());
        return systemDomainInfoMapper.selectList(getSystemDomainInfoDO);
    }

    public List<SystemDomainInfo> getAllList(GetSystemDomainInfoDO getSystemDomainInfoDO){
        PageHelper.clearPage();
        PageHelper.orderBy(getSystemDomainInfoDO.getSortRow()+getSystemDomainInfoDO.getSortOrder());
        return systemDomainInfoMapper.selectList(getSystemDomainInfoDO);
    }

    public int save(SystemDomainInfo info){
        info.setCreateTime(new Date());
        return systemDomainInfoMapper.insertSelective(info);
    }

    public int update(SystemDomainInfo info){
        info.setLastModifiedTime(new Date());
        return systemDomainInfoMapper.updateByPrimaryKeySelective(info);
    }

    public SystemDomainInfo getById(Long id){
        return systemDomainInfoMapper.selectByPrimaryKey(id);
    }

    public int delete(Long id){
        return systemDomainInfoMapper.deleteByPrimaryKey(id);
    }
}
